package Classe;

import java.util.Date;
import java.util.Observable;
import java.util.Observer;
import java.util.UUID;

import Classe.ChambreCategorie;

public class Reservation extends Observable{
	private ListReservationItem listReservationItem;
	private Client m_CLient;
	private UUID NoConfirmation;
	public UUID getNoConfirmation()
	{
		return NoConfirmation;
	}
	private void setClient(Client pClient){
		m_CLient = pClient;
	}
	public Client getClient(){
		return m_CLient;
	}

	public Reservation(Observer o){
		addObserver(o);
		listReservationItem = new ListReservationItem();
		listReservationItem.addObserver(o);
	}
	public void addReservationItem(Date pDebut, Date pFin, int pNbChambre, ChambreCategorie.CategorieChambre pChambreCategorie,Observer o)
	{
		ReservationItem reservationItem = new ReservationItem(pDebut, pFin, pNbChambre, pChambreCategorie);	
		if (o != null)
			reservationItem.addObserver(o);
		if(listReservationItem.add(reservationItem) && o != null)
		{
			reservationItem.DeclancherObserver();
		}
			
	}
	public ListReservationItem getListReservationItem()
	{
		return listReservationItem;
	}
	public void addObserverItem(Observer o)
	{
		listReservationItem.addObserverItem(o);
	}
	public void getData()
	{
		listReservationItem.getData();
	}
	public void confirmer(String pPrenom, String pNom, String pTelephone) {
		Client client = new Client(pPrenom,pNom, pTelephone);
		setClient(client);
		NoConfirmation = UUID.randomUUID();
		setChanged();
		notifyObservers(NoConfirmation);
	}
	public ReservationItem getLigneReservation(int indexReservationItem) {
	  ReservationItem reservationItem =	listReservationItem.getReservationItem(indexReservationItem);
	  return reservationItem;	  
	}
}

